<template>
  <div v-if="crud.props.searchToggle">
    <el-input
      v-model="query.module"
      clearable
      size="small"
      placeholder="所属模块"
      style="width: 200px;"
      class="filter-item"
    />
    <el-input
      v-model="query.username"
      clearable
      size="small"
      placeholder="操作人"
      style="width: 200px;"
      class="filter-item"
    />
    <el-select v-model.number="query.operateType" size="small" placeholder="操作类型" class="filter-item" style="width: 200px">
      <el-option v-for="item in operateTypeList" :key="item.value" :label="item.label" :value="item.value" />
    </el-select>
    <date-range-picker v-model="query.createTime" class="date-item" />
    <rrOperation />
  </div>
</template>

<script>
import { header } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import DateRangePicker from '@/components/DateRangePicker'
import { operateTypeEnum } from '@/api/monitor/log'

export default {
  components: { rrOperation, DateRangePicker },
  mixins: [header()],
  data() {
    return {
      operateTypeList: []
    }
  },
  created() {
    this.loadOperateTypeList()
  },
  methods: {
    loadOperateTypeList() {
      operateTypeEnum().then(res => {
        const list = []
        Object.keys(res).forEach(key => {
          list.push({ value: parseInt(key), label: res[key] })
        })
        this.operateTypeList = list
      })
    }
  }
}
</script>
